<?php

use Phalcon\Mvc\Application;
use Phalcon\Config\Adapter\Ini;
use Phalcon\Db\Adapter\Pdo\Mysql as DbAdapter;

error_reporting(E_ALL & ~E_NOTICE);

define('APP_PATH', realpath('..'));


try {

    /**
     * Read the configuration
     */
    $config = include "./apps/front/config/config.php";

    /**
     * Include services
     */
    require __DIR__ . '/config/services.php';

    /**
     * Handle the request
     */
    $application = new Application($di);

    /**
     * Include modules
     */
    require __DIR__ . '/config/modules.php';

    /**
     * Include routes
     */
    //require __DIR__ . '/config/routes.php';

    $config = new Ini(__DIR__."/apps/inc/config.ini");

 //设置数据库服务
 $di->set('db',function() use ($config) {
      return new DbAdapter(array(
           "host"  =>$config->database->host,
           "username" => $config->database->username,
           "password" => $config->database->password,
           "dbname" => $config->database->name,
           "charset" => "utf8"

 
      ));
   });
 


    echo $application->handle()->getContent();

} catch (Exception $e) {
    echo $e->getMessage();
}

